package com.zhumengquan.wozhi.controller;

import com.zhumengquan.wozhi.domain.User;
import com.zhumengquan.wozhi.service.FindAllUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class FindAllUserController {

    @Autowired
    private FindAllUserService find;

    @RequestMapping("/alluser")
    @ResponseBody
    public List getSectionLoadQuota (){
//        System.out.println("hi");
        List<User> result =find.getUser();
        return result;
    }

//    public void utils() {
//        try {
//            //第一步 按官网四步走，得到sqlSession
//            String resource = "application.properties";
//            InputStream inputStream = Resources.getResourceAsStream(resource);
//            SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(inputStream);
//            SqlSession sqlSession = factory.openSession();
//            //第二步，进行查询
//            UserMapper a = sqlSession.getMapper(UserMapper.class);
////            List<User> result = a.findAllUser();//查询方法的名称
//            User result = a.findUserById(2);
//            //打印结果
//            System.out.println(result);
//            //关闭连接
//            sqlSession.close();
//            inputStream.close();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//    public static void main(String[] args) {
//        utils a=new utils();
//        a.utils();
//    }
}